<?php

class SiteController extends MyController
{
	private $pagesize = 10;
	private $linkpagesize = 20;
	private $cache_time = 0;
	public function init()
	{
		parent::init();
		header("Content-type: text/html; charset=utf-8");
	}

	public $css = array();
	public $meta_keywords;
	public $meta_description;
	public $meta_author;
	/**
	 * 首页
	 */
	public function actionIndex()
	{
		$data = array();
		$data['products'] = Products::model()->findAll();
		$this->pageTitle = '首页';
		$this->render('index',$data);
	}

	/*
	* 根据id显示推荐正文
	*/
	public function actionArticle()
	{
		$id = intval(Yii::app()->request->getParam('id'));
		$article = Products::model()->findByPk($id);
		if(!$id || !$article || !$article->published)
			throw new CHttpException(404);
		$this->pageTitle = $article->title;
		$this->render('article',array('article'=>$article));
	}

	/*
	* 跳转
	*/
	public function actionRedirect()
	{
		$id = intval(Yii::app()->request->getParam('id'));
		$prd = Products::model()->findByPk($id);
		if($prd)
		{
			Prd_visit_log::_dolog($id);
			$this->redirect(SiteAnalyzer::analyzerFactory($prd->item_url)->get_refund_url());
		}
		else
		{
			$this->redirect('/');
		}
	}

	/*
	* 评价
	*/
	public function actionReview()
	{
		//param id
		//score 1-10
		//comment
		//ip check
	}
}